﻿using System.ComponentModel;

namespace Borg
{
    public enum SizeMode
    {
        Auto,
        Percent,
        Pixel
    }

    public enum LayoutOrientation
    {
        Default,
        Stacked,
        SideBySide
    }

    public class LayoutInfo : INotifyPropertyChanged
    {
        private double _nestingLevel;
        private double _order;
        private string _panel;
        private double _size;

        private SizeMode _sizeMode;

        public event PropertyChangedEventHandler PropertyChanged;

        public LayoutInfo(string panel, double order)
        {
            _panel = panel;
            _order = order;
        }

        public LayoutInfo(double nestingLevel, double order, SizeMode sizeMode, double size)
            : this(string.Empty, nestingLevel, order, sizeMode, size)
        { }

        public LayoutInfo(string panel, double order, SizeMode sizeMode, double size)
            : this(panel, order)
        {
            _sizeMode = sizeMode;
            _size = size;
        }

        public LayoutInfo(string panel, double nestingLevel, double order, SizeMode sizeMode, double size)
            : this(panel, order, sizeMode, size)
        {
            _nestingLevel = nestingLevel;
        }

        public static LayoutInfo CreateHostLayoutInfo()
        {
            return new LayoutInfo(0.0, 0.5, SizeMode.Percent, 1.0);
        }

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        public double NestingLevel
        {
            get { return _nestingLevel; }
            set
            {
                if (_nestingLevel == value)
                    return;

                _nestingLevel = value;
                OnPropertyChanged("NestingLevel");
            }
        }

        public double Order
        {
            get { return _order; }
            set
            {
                if (_order == value)
                    return;

                _order = value;
                OnPropertyChanged("Order");
            }
        }

        public string Panel
        {
            get { return _panel; }
            set
            {
                if (_panel == value)
                    return;

                _panel = value;
                OnPropertyChanged("Panel");
            }
        }

        public double Size
        {
            get { return _size; }
            set
            {
                if (_size == value)
                    return;

                _size = value;
                OnPropertyChanged("Size");
            }
        }

        public SizeMode SizeMode
        {
            get { return _sizeMode; }
            set
            {
                if (_sizeMode == value)
                    return;

                _sizeMode = value;
                OnPropertyChanged("SizeMode");
            }
        }
    }
}

